Imports System.Data.SqlClient
Imports System.Data
Partial Class SupplierWisePurchase
    Inherits System.Web.UI.Page
    Dim da As SqlDataAdapter
    Dim ds As New DataSet
    Dim cn As New SqlConnection("Data Source=SAI-D2190A07F04\SQLEXPRESS;Initial Catalog=j1;Integrated Security=True")
    Dim _EmployeeId As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        _EmployeeId = Session("EmpId")
        If Not Page.IsPostBack Then
            da = New SqlDataAdapter("select * from SupplierMaster", cn)
            da.Fill(ds, "SupplierMaster")
            DropDownList1.DataSource = ds.Tables(0)
            DropDownList1.DataTextField = "SupplierName"
            DropDownList1.DataValueField = "SupplierId"
            DropDownList1.DataBind()
            CrystalReportViewer1.SelectionFormula = "{SupplierMaster.SupplierId}='" & DropDownList1.Text & "' and {SupplierMaster.SupplierId}={PurchaseMaster.SupplierId}"
        End If
    End Sub
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        CrystalReportViewer1.ReportSource = "~/Reports/SupplierWisePurchase.rpt"
        CrystalReportViewer1.SelectionFormula = "{SupplierMaster.SupplierId}='" & DropDownList1.Text & "' and {SupplierMaster.SupplierId}={PurchaseMaster.SupplierId}"
    End Sub
    Protected Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
        Session("EmpId") = _EmployeeId
        Response.Redirect("../Admin/frmReport.aspx")
    End Sub
End Class
